import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/pages/Home'
import About from '@/pages/About'
import Message from '@/pages/Message'
import News from '@/pages/News'
import Detail from '@/pages/Detail'

Vue.use(VueRouter)

export default new VueRouter({
  mode:'history',
  routes:[
    {
      path:'/home',
      name:'zhuye',
      component:Home,
      children:[
        {
          path:'message',
          name:'xiaoxi',
          component:Message,
          children:[
            {
              path:'detail',
              name:'xiangqing',
              component:Detail,
              // props的第二种写法，值为布尔值，可以把该路由规则收到的params参数一个一个的传给路由组件
              // props:true

              // props的第三种写法，值为函数
              props($route){
                console.log('@',$route)
                return {...$route.query,a:100}
              }
            }
          ]
        },
        {
          path:'news',
          name:'xinwen',
          component:News
        }
      ]
    },
    {
      path:'/about',
      name:'guanyu',
      component:About,
      // props的第一种写法，值为对象，可以把props中每一组key-value传给对应的路由组件
      /* props:{
        a:1,
        b:'哈哈'
      } */
    }
  ]
})


